package cn.com.surker.base.pump.service.impl;

import cn.com.surker.base.pump.dao.CastModeDao;
import cn.com.surker.base.pump.entity.CastMode;
import cn.com.surker.base.pump.service.CastModeService;
import cn.com.surker.enums.StateEnum;
import cn.com.surker.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 浇筑方式表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2024-07-25
 */
public abstract class CastModeBaseImpl extends ServiceImpl<CastModeDao, CastMode> implements CastModeService {

	@Resource
	protected CastModeDao castModeDao;

	@Override
	public CastMode findByErpId(Long originId, Long erpId) {
		return castModeDao.findByErpId(originId, erpId);
	}

	@Override
	public List<CastMode> findIdByNames(String... names) {
		if (names == null || names.length < 1) {
			return null;
		}
		QueryWrapper<CastMode> qw = new QueryWrapper<>();
		qw.eq("status", StateEnum.ENABLED.getCode());
		qw.in("name", names);
		List<CastMode> castModes = castModeDao.selectList(qw);
		return castModes;
	}

	@Override
	public List<CastMode> findList(String name) {
		QueryWrapper<CastMode> qw = new QueryWrapper<>();
		qw.eq("status", StateEnum.ENABLED.getCode());
		if (StringUtils.isNotBlank(name)) {
			qw.like("name", name);
		}
		List<CastMode> castModes = castModeDao.selectList(qw);
		return castModes;
	}
}